home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15447 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: snews.tcel.com!netway
  2. From: tech@netway.ab.ca (Ritchie Annand)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Function Prototypes in C++
  5. Date: 5 Apr 1996 10:41:18 GMT
  6. Organization: Telnet Canada (403) 262-5859 info@tcel.com
  7. Message-ID: <4k2tce$99u@challenge.tcel.com>
  8. References: <4junnq$2k1@phoenix.csc.calpoly.edu>
  9. NNTP-Posting-Host: 204.209.150.53
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4junnq$2k1@phoenix.csc.calpoly.edu>,
  13.    nbonfili@phoenix.csc.calpoly.edu (Nicholas R Bonfilio) wrote:
  14. >I know that function prototypes are required in standard C++ as opposed to C
  15. >where they are not required.  But, what I don't know for certain is the 
  16. >rules regarding the scoping of function protos...
  17.  
  18. You don't need a function prototype if you've fully-defined the function by 
  19. the time you reach main() (you can put the functions above main in the 
  20. source).  For those cases when you have a case of mutual use, or you put them 
  21. after main, the prototypes must come outside of a function, before any 
  22. functions that need to use it.  (Note: this way, you can separate out the 
  23. header and implementation into .hpp/.cpp)
  24.  
  25. Mind you, most C++ programming, you'll want to do with classes.  In that 
  26. case, the whole class definition with method prototypes is like a list of 
  27. function prototypes (with thisClassName:: on the front) - that goes in the 
  28. hpp file, and the implementation that uses those methods goes in the .cpp 
  29. file (usually), so you don't need to make any "extra" prototypes for the 
  30. methods inside classes.
  31.  
  32.   --=- Ritchie A.
  33.